Accusoft.OCRXpress.nodejs
Get Result Elements (Word, Character, Textlines, etc.)

The Results Manager is a collection of Get functions that allow certain Result objects to be accessed. For more information, see Results Manager.

A result element can be any of the Result objects returned from recognition.

The call to recognize() returns a Document object that serves as the base result with which to access all other result elements.

Copy Code
// Get the base document object.
recognize(recognitionParameters, function(error, document){…});

With this object, applications can get a reference to any descendant element of a given result element. The below code example will show how to get a particular word and then the area (or location) for that word:

Copy Code
// Get the fifth word of the second region in the document.
var word = document.getRegions()[1].getWords()[4];
// Get the width (in pixels) of the word.
var wordWidth = word.area.width;

The below code example shows how to count the number of words in the first line of text in a document.

Copy Code
// Get the first text line in the document.
var textLine = document.getTextLines()[0];
// Get where the word occurs in the image.
var numberOfWords = textLine.getWords().length ;

In order to copy text out of OCR Xpress for Node.js , the application simply has to access the text property of a result.

In the following example code, the result element being accessed is the fifth word of the second region in a document we accessed above.

Copy Code
// Copy the text into a string object.
var text = word.text;
// Do something with the text.

area

Gets the area or location on the page, in pixel units, of a given result element.

Copy Code
var area = word.area;

confidence

Gets the confidence of a given character element. Other result types do not have a confidence associated with them.

Copy Code
var confidence = word.getCharacters()[0].confidence;

orientation

Gets the orientation of a given page element. Other result types do not have an orientation associated with them.

Copy Code
var orientation = document.getPages()[0].orientation;

  

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback